package com.dys.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @className: com.dys.filter.Filter02
 * @description: 注解模式开发过滤器: 过滤器文件的命名会影响过滤器的执行顺序
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/09/24 22:19
 */
@WebFilter(filterName = "filter03", servletNames = "servlet01")
public class Filter03_Sort implements Filter {
    public Filter03_Sort() {
        System.out.println("Filter03_Sort的构造器......");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("Filter03_Sort 自定义过滤init()初始化方法......");
        // 读取初始化参数
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("执行Filter03_Sort的 doFilter() 方法......");
        System.out.println("Filter03_Sort 正在过滤请求");
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("Filter03_Sort 正在过滤响应");
    }

    @Override
    public void destroy() {
        System.out.println("Filter03_Sort 自定义过滤器destroy()销毁方法......");
    }
}
